package com.qf;

import com.qf.conf.LoadBalancerConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
//开启服务发现
@EnableDiscoveryClient

//设置qf-order服务的负载均衡策略
@LoadBalancerClient(value = "qf-order",configuration = LoadBalancerConfig.class)

//启用Feign客户端扫描
@EnableFeignClients
public class QFUserApplication {

    public static void main(String[] args) {
        SpringApplication.run(QFUserApplication.class, args);
    }


    @Bean
    @LoadBalanced //会向RestTemplate注入一个LoadBalancerInterceptor
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

}
